package cn.com.longfuinfo.wx.interceptor;

import com.jfinal.aop.Interceptor;
import com.jfinal.aop.Invocation;

import cn.com.longfuinfo.wx.common.Constants;
import cn.com.longfuinfo.wx.controller.BaseController;
import cn.com.longfuinfo.wx.dao.User;
import cn.com.longfuinfo.wx.service.UserService;

/**
 * 判断用户当前已经登录， 再查询一次最新信息并放在session中
 */
public class RefreshLoginInterceptor implements Interceptor{
	private UserService userService = new UserService();

	@Override
	public void intercept(Invocation inv) {
		BaseController c = (BaseController)inv.getController();
		//如果用户当前已经登录， 再查询一次最新信息并放在session中
		User user = c.getCurrentUser();
		if(user!=null){
			c.setSessionAttr(Constants.USER, userService.findByUser(c.getCurrentUserid()));
		}
		inv.invoke();
	}
}
